package com.ytjj.qmyx.admin.service.impl;

import com.github.pagehelper.PageHelper;
import com.ytjj.common.api.CommonPage;
import com.ytjj.qmyx.admin.dao.PathConfigDao;
import com.ytjj.qmyx.admin.model.request.PathConfigRequest;
import com.ytjj.qmyx.admin.service.PathConfigService;
import com.ytjj.qmyx.mall.model.PathConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PathConfigServiceImpl implements PathConfigService {

    @Autowired
    private PathConfigDao pathConfigDao;

    @Override
    public CommonPage<PathConfig> selectList(PathConfigRequest pathConfigRequest) {
        PageHelper.startPage(pathConfigRequest.getPageNum(), pathConfigRequest.getPageSize());
        List<PathConfig> pageList = pathConfigDao.selectList(pathConfigRequest);
        return CommonPage.restPage(pageList);
    }

    @Override
    public int insertPathConfig(PathConfigRequest pathConfigRequest) {
        pathConfigRequest.setCreateTime(new Date());
        return pathConfigDao.insertPathConfig(pathConfigRequest);
    }

    @Override
    public int updatePathConfig(PathConfigRequest pathConfigRequest) {
        pathConfigRequest.setUpdateTime(new Date());
        return pathConfigDao.updatePathConfig(pathConfigRequest);
    }

}
